﻿using System.Data;
using Loki.Data;
using Luna.Model;

namespace Luna.Data.Mappers
{
    public class NamedEntityDataMapper : LunaEntityMapper<NamedEntityData, INamedEntityData>
    {
        public const string COL_NAME = "Name";
        public const string COL_DESCRIPTION = "Description";

        protected override void LoadCoreData(INamedEntityData P_Entity, IDataRecord P_Record)
        {
            P_Entity.Name = P_Record.GetString(COL_NAME);
            P_Entity.Description = P_Record.GetString(COL_DESCRIPTION);
        }

        protected override void MapSaveParameters(IDatabaseCommand P_Command, INamedEntityData P_Entity)
        {
            P_Command.AddParameter(COL_NAME, P_Entity.Name);
            P_Command.AddParameter(COL_DESCRIPTION, P_Entity.Description);
            P_Command.AddParameter(COL_ID, P_Entity.PK);
        }
    }
}
